// import config from '@/config';
// import moment, { Moment } from 'moment';
// import { message } from 'ant-design-vue';
// import store from '@/store';
// import router from '@/router';
// import qs from 'qs';

const util = {
    /**
     * 判断是不是字面量对象
     *
     * @param {*} data
     * @returns {boolean}
     */
    isObject(data: any): boolean {
        return {}.toString.call(data) === '[object Object]';
    },
    /**
     * 深度拷贝数据
     *
     * @template T
     * @param {T} data
     * @returns {T}
     */
    deepCopy<T>(data: T): T {
        try {
            return JSON.parse(JSON.stringify(data));
        } catch (e) {
            console.error(e);
            return data;
        }
    },
    /**
     * 创建uuid
     *
     * @returns {string}
     *
     */
    createUuid(): string {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
            // tslint默认禁止位操作，可以通过注释让tslint忽略该问题
            // tslint:disable-next-line: no-bitwise
            const r = (Math.random() * 16) | 0;
            // tslint:disable-next-line: no-bitwise
            const v = c === 'x' ? r : (r & 0x3) | 0x8;
            return v.toString(16);
        });
    },
};

export default util;
